package com.cloudeasy.post.util;

import com.cloudeasy.api.vo.post.VoteVO;
import com.cloudeasy.post.po.Vote;
import org.springframework.beans.BeanUtils;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * 点赞工具类
 */
public class VoteUtil {
    /**
     * 转换VO对象
     *
     * @param vote {@link Vote}
     * @return {@link VoteVO}
     */
    public static VoteVO convert(Vote vote) {
        VoteVO voteVO = new VoteVO();
        BeanUtils.copyProperties(vote, voteVO);
        return voteVO;
    }

    /**
     * 转换VO对象
     *
     * @param votes {@link List<Vote>}
     * @return {@link List<VoteVO>}
     */
    public static List<VoteVO> convert(List<Vote> votes) {
        return votes.stream().map(VoteUtil::convert).collect(Collectors.toList());
    }
}
